﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace ScarEngine
{
    public class TextComponent : DrawableComponent
    {

        public string Text;
        public SpriteFont Font;

        public TextComponent()
            : base()
        {
            Text = "";
            Font = Game1.MasterManager.DefaultFont;
            MasterManager.GraphicsManager.RegisterComponent(this);
        }


        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            PositionalComponent P = Object.Get<PositionalComponent>();
            spriteBatch.DrawString(Font, Text, P.Position, Color);
        }


        #region Core
        public override void Delete()
        {
            MasterManager.GraphicsManager.UnRegisterComponent(this);
            base.Delete();
        }

        public override void Prerequisites()
        {
            if (Object.HasComponent<PositionalComponent>() == false)
            {
                Object.Add<PositionalComponent>("Position");
            }
            base.Prerequisites();
        }

        #endregion


    }
}